﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace E2_WEBSITE.Code.Comment
{    
    public class CommentController
    {
        private CommentDataAccess m_CommentDAO = new CommentDataAccess();

        public bool insertComment(int idUser, int idProduct, int iVote)
        {
            try
            {
                if (m_CommentDAO.checkCommentExist(idUser, idProduct))
                {
                    return m_CommentDAO.updateComment(idUser, idProduct, iVote);
                }
                else
                {
                    return m_CommentDAO.insertComment(idUser, idProduct, iVote);
                }                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public List<CommentInfo> getListCommentByIDProduct(int idProduct)
        {
            try
            {
                return m_CommentDAO.getListCommentByIDProduct(idProduct);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }        
    }
}
